package com.iflytek.universitymanagement.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.iflytek.universitymanagement.domain.Student;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author louyp
 * @since 2024-11-26
 */
@Mapper
public interface StudentMapper extends BaseMapper<Student> {
//    @Select("SELECT * FROM student WHERE name = #{name}")
//    Student selectByName(String name);

    @Insert("insert into `student` ( name, password, gender, age, student_number, enrollment_year,contact,email,role) " +
            "values (#{name}, #{password}, #{gender}, #{age}, #{studentNumber}, #{enrollmentYear}, #{contact}, #{email}, #{role})")
    void insertStudent(Student student);



    // 根据学生名字查询学生 ID
    @Select("SELECT student_id FROM student WHERE name = #{studentName}")
    Integer getStudentIdByName(String studentName);


    // 根据学生姓名查询学生信息
    @Select("SELECT * FROM student WHERE name = #{name}")
    Student selectByName(String name);

    void update(Student dbStudent);


}
